package controlFlowGraph;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import config.GlobalConfig;

public class CFG {
	
	public static List<CFGNode> alreadyLabeled = new ArrayList<CFGNode>();

	private Set<CFGNode> allNodes;
	
	private CFGNode startNode;
	
	private CFGNode endNode;
	
	public CFG(Set<CFGNode> a, CFGNode s, CFGNode e) {
		this.allNodes = a;
		this.startNode = s;
		this.endNode = e;
		if (GlobalConfig.debug) {
			System.out.println("We have the following nodes: " + allNodes.toString());
		}
	}
	
	public Set<CFGNode> getAllNodes() {
		return this.allNodes;
	}
	
	public void addCFGNode(CFGNode n) {
		this.allNodes.add(n);
	}
	
	public String toGraphVisualization() {
		alreadyLabeled.clear();
		String result = "digraph G {\n";
		result += startNode.toGraphVisualization();
		return result + "}\n";
	}

	public String asOutput() {
		alreadyLabeled.clear();
		String result = "TRANSFORMATION_RESULT\n";
		result += startNode.asOutput();
		return result;
	}
	
}
